#include <bits/stdc++.h>
// 2025/02/05
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

int n, a[3000001], f[3000001];
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    stack<int> num, pos;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        while (!num.empty() && num.top() < a[i]){
            f[pos.top()] = i;
            num.pop();
            pos.pop();
        }
        num.push(a[i]);
        pos.push(i);
    }
    for (int i = 1; i <= n; i++)
        cout << f[i] << " ";
    return 0;
}